<%@page import="com.lyf.util.DateUtil"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp" %>

<!DOCTYPE html>
<!-- saved from url=(0038)http://192.168.0.77/pms/idea_show.html -->
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" type="text/css" href="${basePath }/css/bootstrap.min.css">
	<script type="text/javascript" src="${basePath }/js/jquery-1.8.2.min.js"></script>
	<!-- <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script> -->
	<script type="text/javascript" src="${basePath }/js/bootstrap.min.js"></script>
</head>
<body class="body">
	
	<jsp:include page="include/top.jsp"></jsp:include>
	
	
	<div class="container">
	  <div class="row">
		
		<jsp:include page="include/side.jsp">
			<jsp:param value="idea" name="tag"/>
		</jsp:include>
		
		<div class="span9">
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px">
				<li class="active">
					<a href="http://192.168.0.77/pms/idea.html"><i class="icon-fire"></i>想法</a>&gt;使用Ajax技术
				</li>
				
			</ul>
			<div class="wall">
				  <div class="page-header">
				  	 <c:set var="time" value="${idea.i_createTime }"></c:set>
					  <%
					  	 String time = (String)pageContext.getAttribute("time");
					   	 time = DateUtil.getAskedTime(time);
					   	 pageContext.setAttribute("time",time);
					  %>
					<h3>${idea.i_name }&nbsp;&nbsp;<small>${idea.employee.username }发布于 ${time }</small></h3>
				  </div>
				  <p>${idea.i_describle }</p>
				  
				  <div class="line">
					评论
				  </div>
				  <form onsubmit="return false">
					<textarea name="desc" id="desc" class="span8" rows="5"></textarea>
					<br>
					<button class="btn" id="btn">发布</button>
				  </form>
				 <blockquote id="discuss-list"></blockquote>
				 <c:forEach items="${ideaDiscussList }" var="i">
				 <blockquote>
				  ${i.id_content }
				  <small>
				  	<c:set var="time2" value="${i.id_createTime }"></c:set>
					  <%
					  	 String time2 = (String)pageContext.getAttribute("time2");
					   	 time2 = DateUtil.getAskedTime(time2);
					   	 pageContext.setAttribute("time2",time2);
					  %>
					${i.employee.username }发布于 ${time2 }
					<a href="javascript:;" onclick="edit(this)" id="${i.id }" title="编辑"><i class="icon-pencil"></i></a>
				    <a href="javascript:;" onclick="del(this)" id="${i.id }" title="删除"><i class="icon-trash"></i></a>
				  </small>
				  
				</blockquote>
				</c:forEach>
				
				<a href="${basePath }/idea/toIdea">←返回想法列表</a>
			</div>
		</div>
	  </div>
	</div>
	<script type="text/javascript">
	 	$("#btn").click(function(){
			if($("#desc").val().trim() != ""){
				$.post("${basePath}/idea/addIdeaDiscuss",{"desc":$("#desc").val().trim()},function(obj){
					var content = "<blockquote>"+ obj.id_content +
										"<small>" + obj.employee.username + "发布于" + obj.id_createTime +
											"<a title='编辑' href='javascript:;' onclick='edit(this)' id='" + obj.id + "'>" +
												"&nbsp;<i class='icon-pencil'></i>&nbsp;" +
											"</a>" +
											"<a title='删除' href='javascript:;' onclick='del(this)' id='" + obj.id + "'>" +
												"&nbsp;<i class='icon-trash'></i>&nbsp;" + 
											"</a>" +
										"</small>" + 
								  "</blockquote>";
					$("#discuss-list").after(content);
					$("#desc").val(" ");
				});
			}else{
				alert("评论内容不能为空");
			}
	 	});
	 	function del(obj){
	 		var id = $(obj).attr("id");
			$.post("${basePath}/idea/delDiscuss",{"id":id},function(){
				$(obj).parent().parent().remove();
			});
	 	}
	 </script>
</body></html>
